#!/usr/bin/env python3
"""
独立的代码审计服务
端口: 8043
"""
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from audit import router as audit_router

app = FastAPI(title="Code Audit Service", version="1.0.0")

# CORS配置
app.add_middleware(
    CORSMiddleware,
    allow_origins=[
        "http://localhost:5173",
        "http://127.0.0.1:5173",
        "http://localhost:5174",
        "http://127.0.0.1:5174",
        "*"
    ],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 注册审计路由
app.include_router(audit_router)

@app.get("/")
def root():
    return {
        "service": "Code Audit Service",
        "version": "1.0.0",
        "status": "running",
        "endpoints": ["/api/audit"]
    }

@app.get("/health")
def health_check():
    return {"status": "healthy"}

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(
        app,
        host="0.0.0.0",
        port=8043,
        log_level="info"
    )
